<!DOCTYPE html>
<html>

<head>
    <#include "/yq/admin/components/meta.html" />
    <title>蓁奕科技 ${metaTitleSuffix!}</title>
    <#include "/yq/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="2-3" />
            <#include "/yq/admin/components/menu.html" />
            <el-container>
                <#include "/yq/admin/components/header.html" />
                <el-main>
                    <template>
                        <!-- <el-button @click='onAdd'>新增</el-button> -->
                        <el-row class="search">
                            <el-date-picker v-model="dateRange" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" unlink-panels="true" :default-value="new Date">
                            </el-date-picker>
                            <el-select v-model="shopId" clearable filterable placeholder="商户" v-if="${userRole!2} == 0 || ${userRole!2} == 1">
                                <el-option v-for="item in shops" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                            <el-input v-model="productName" clearable placeholder="商品名称" style="width: 217px;"></el-input>
                            <el-button @click="onSearch"><i class="el-icon-search"></i>筛选</el-button>
                            <el-button @click="goDownload">下载</el-button>
                        </el-row>
                        <el-table :data="items" style="width: 100%">
                            <!-- <el-table-column prop="id" label="id">
                            </el-table-column> -->
                            <el-table-column prop="userName" label="用户昵称">
                            </el-table-column>
                            <el-table-column prop="productName" label="产品名称">
                            </el-table-column>
                            <el-table-column prop="shopName" label="商户名称">
                            </el-table-column>
                            <el-table-column prop="shopUserName" label="商户账户名">
                            </el-table-column>
                            <el-table-column prop="price" label="价格">
                            </el-table-column>
                            <el-table-column prop="type" label="类型">
                                <template slot-scope="scope">
                                    <span v-if='scope.row.type == 1'>核销</span>
                                    <span v-if='scope.row.type == 0'>扫码支付</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="addTime" label="时间">
                            </el-table-column>
                            <!-- <el-table-column  label="操作">
                                <template slot-scope="scope">
                                    <el-button type="text" @click="onEdit(scope.row)">查看</el-button>
                                    <el-button type="text" @click="onDelte(scope.row)" style="color: red;">删除</el-button>
                                </template>
                            </el-table-column> -->
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/yq/admin/components/footer.html" />
    </div>
    <#include "/yq/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                items: ${items!'[]'},
                dateRange: '',
                shopId: '${shopId!}' ? Number('${shopId!}') : '',
                shops: toJson(`${shops}`),
                productName: '${productName!}'
            }
        },
        mounted: function() {
            var startTime = '${startTime!""}'
            if (startTime != '') {
                this.dateRange = new Array;
                this.dateRange.push('${startTime!}');
                this.dateRange.push('${endTime!}');
            }
        },
        methods: {
            onEdit(info) {
                window.location.href = '/yq/admin/category/info?id=' + info.id;
            },
            onDelte(info) {
                this.$confirm('确定删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {
                        id: info.id
                    }
                    axiosRequest(param, '/yq/admin/category/delete', '')
                }).catch(() => {});
            },
            onSearch() {
                var self = this;
                var keys = [
                    { key: 'shopId', value: self.shopId },
                    { key: 'productName', value: self.productName }
                ]
                if (self.dateRange != null && self.dateRange.length > 1) {
                    keys.push({ key: 'startTime', value: self.dateRange[0] });
                    keys.push({ key: 'endTime', value: self.dateRange[1] });
                } else {
                    keys.push({ key: 'startTime', value: '' });
                    keys.push({ key: 'endTime', value: '' });
                }
                goPage(1, keys);
            }
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
</body>

</html>